var pwdlegal =false;
var emaillegal =false;

function verifypassword()
{
	if(document.getElementById("password").value=="")
	{
		document.getElementById("passwordcheck").innerText="password is empty";
		pwdlegal=false;
		return;
	}
	var length=document.getElementById("password").value.length;
	if(length<5)
	{
		document.getElementById("passwordcheck").innerText="password is too short";
		pwdlegal=false;
		return;
	}
	if((document.getElementById("password").value)!=(document.getElementById("confirmpassword").value))
	{
		document.getElementById("passwordcheck").innerText="two password entry not match";
		pwdlegal=false;
		return;
	}
	document.getElementById("passwordcheck").innerText="";
	pwdlegal=true;
	return;
}

function verifyemail()
{
    var email=document.getElementById("email").value;
    if (email=="")
        emaillegal=true;
    else
    {
        var pattern=/^([a-zA-Z0-9_-])+@([a-zA-Z0-9_-])+(\.[a-zA-Z0-9_-])+/;
        emaillegal=pattern.test(email);
    }
    if (emaillegal)
		document.getElementById("emailcheck").innerText="";
    else
		document.getElementById("emailcheck").innerText="email address illegal";
}
function check()
{
	verifypassword();
	verifyemail();
	if ((pwdlegal)&&(emaillegal))
	{
		document.getElementById("infoerror").style.visibility="hidden";
		return true;
	}
	else
	{
		document.getElementById("infoerror").style.visibility="visible";
		return false;
	}
	return false;
}
// JavaScript Document